#include "widget.h"
#include "ui_widget.h"
#include <QLabel>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    int count = ui->tabWidget->count();
    QWidget *w = new QWidget();
    ui->tabWidget->addTab(w, QString("Tab") + QString::number(count + 1));

    QLabel *label_1 = new QLabel(w);
    label_1->setText(QString("标签页") + QString::number(count + 1));

    ui->tabWidget->setCurrentIndex(count);
}

void Widget::on_pushButton_2_clicked()
{
    int index = ui->tabWidget->currentIndex();
    ui->tabWidget->removeTab(index);
}
